package com.longcai.service.impl.nearby;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.longcai.bean.ApiResult;
import com.longcai.entity.nearby.ClyjTradingArea;
import com.longcai.mapper.nearby.ClyjTradingAreaMapper;
import com.longcai.service.nearby.ClyjTradingAreaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商圈表 服务实现类
 * </p>
 *
 * @author M
 * @since 2019-04-02
 */
@Service
public class ClyjTradingAreaServiceImpl extends ServiceImpl<ClyjTradingAreaMapper, ClyjTradingArea> implements ClyjTradingAreaService {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private ClyjTradingAreaMapper clyjTradingAreaMapper;

    public ApiResult getTradingArea(String province, String city, String country) {
        try {
            QueryWrapper<ClyjTradingArea> queryWrapper = new QueryWrapper();
            queryWrapper.eq("s_province", province);
            queryWrapper.eq("s_city", city);
            queryWrapper.eq("s_county", country);
            queryWrapper.eq("status", 0);
            List<ClyjTradingArea> clyjTradingAreaList = this.clyjTradingAreaMapper.selectList(queryWrapper);
            logger.debug("查询成功");
            return ApiResult.success(clyjTradingAreaList);
        } catch (Exception e) {
            logger.error("查询失败");
            e.printStackTrace();
            return ApiResult.fail("查询失败" + e.getMessage());
        }

    }
}
